package com.example.robertluozizhao.framecollectdemo.activity;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.Button;

import com.example.robertluozizhao.framecollectdemo.R;
import com.example.robertluozizhao.framecollectdemo.adapter.PageItemRvAdapter;
import com.example.robertluozizhao.framecollectdemo.common.Constants;
import com.example.robertluozizhao.framecollectdemo.data.test.TestRcycleitemBean;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by robert.luozizhao on 2018/2/2.
 */

public class AdapterCheckActivity extends AppCompatActivity {
    @BindView(R.id.rv01)
    RecyclerView rv01;
    @BindView(R.id.rv02)
    RecyclerView rv02;
    @BindView(R.id.add)
    Button add;
    private PageItemRvAdapter mPageItemRvAdapter;
    private TestRcycleitemBean testRcycleitemBean01;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_adapter_check);
        ButterKnife.bind(this);
        TestRcycleitemBean testRcycleitemBean01 = new TestRcycleitemBean(R.mipmap.ic_launcher, "01", Constants.ITEM_TYPE_ONE);
        TestRcycleitemBean testRcycleitemBean02 = new TestRcycleitemBean(R.mipmap.ic_launcher, "02", Constants.ITEM_TYPE_TWO);
        ArrayList<TestRcycleitemBean> list = new ArrayList<>();
        list.add(testRcycleitemBean01);
        list.add(testRcycleitemBean02);
        list.add(testRcycleitemBean02);
        list.add(testRcycleitemBean02);
        list.add(testRcycleitemBean02);
        list.add(testRcycleitemBean02);
        list.add(testRcycleitemBean02);


        LinearLayoutManager linearLayoutManager1 = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
//        rv.setHasFixedSize(true);
        rv01.setLayoutManager(linearLayoutManager1);
        mPageItemRvAdapter = new PageItemRvAdapter(list);
        rv01.setAdapter(mPageItemRvAdapter);
        rv01.setItemAnimator(new DefaultItemAnimator());
        rv01.setAdapter(mPageItemRvAdapter);
/*
        LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
//        rv.setHasFixedSize(true);
        rv02.setLayoutManager(linearLayoutManager2);
        rv02.setAdapter(new PageItemRvAdapter(list));
        rv02.addItemDecoration(new DividerItemDecoration(this,DividerItemDecoration.VERTICAL));
*/


    }


    @OnClick({R.id.add})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.add:
                mPageItemRvAdapter.addData(new TestRcycleitemBean(R.mipmap.ic_launcher, "test01", Constants.ITEM_TYPE_ONE));
                break;
        }
    }
}
